
import javax.swing.JOptionPane;

/*
 * PesquisaCandidato.java
 *
 * Created on 25 de Junho de 2008, 15:50
 */

/**
 *
 * @author  Bárbara
 */
public class DeletaCandidato extends javax.swing.JFrame {

    /** Creates new form PesquisaCandidato */
    public DeletaCandidato() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btApagarCand = new javax.swing.JButton();
        btLimparPesqCand = new javax.swing.JButton();
        btCancPesqCand = new javax.swing.JButton();
        NomePesqCand = new javax.swing.JLabel();
        TextApagarCand = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Deletando um Candidato");

        btApagarCand.setText("Pesquisar");
        btApagarCand.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btApagarCandActionPerformed(evt);
            }
        });

        btLimparPesqCand.setText("Limpar");

        btCancPesqCand.setText("Cancelar");

        NomePesqCand.setFont(new java.awt.Font("Tahoma", 1, 12));
        NomePesqCand.setText("Nome do Candidato:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(79, 79, 79)
                        .addComponent(btApagarCand)
                        .addGap(37, 37, 37)
                        .addComponent(btLimparPesqCand)
                        .addGap(35, 35, 35)
                        .addComponent(btCancPesqCand))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(NomePesqCand)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
                        .addComponent(TextApagarCand, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addContainerGap(21, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(NomePesqCand)
                    .addComponent(TextApagarCand, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 63, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btCancPesqCand)
                    .addComponent(btLimparPesqCand)
                    .addComponent(btApagarCand))
                .addGap(27, 27, 27))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btApagarCandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btApagarCandActionPerformed
// TODO add your handling code here:
    Candidato c = new Candidato();
    c.setNome(TextApagarCand.getText());

    //passa para o método cadastrar todas as informações digitadas sobre o funionário
    GerenciaCandidato gc = new GerenciaCandidato();
    try {
        gc.deletar(c.getNome());
        JOptionPane.showMessageDialog(null, "CANDIDATO:  " + c.getNome() + " REMOVIDO!");
        dispose();
        
    } catch (Exception e1) {
        //JOptionPane.showMessageDialog(null, "ERRO: Informações não passadas corretamente!");
    }
}//GEN-LAST:event_btApagarCandActionPerformed

    /**
    * @param args the command line arguments
    */
    public void exibir() {
           setVisible(true);
    }
 

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel NomePesqCand;
    private javax.swing.JTextField TextApagarCand;
    private javax.swing.JButton btApagarCand;
    private javax.swing.JButton btCancPesqCand;
    private javax.swing.JButton btLimparPesqCand;
    // End of variables declaration//GEN-END:variables

}
